package com.zdy.im.tio.command.handler;


import com.zdy.im.common.exception.ImException;
import com.zdy.im.core.ICommand;
import com.zdy.im.tio.command.AbstractCommandHandler;
import com.zdy.im.tio.command.Command;
import org.springframework.stereotype.Component;
import org.tio.core.ChannelContext;
import org.tio.core.intf.Packet;

/**
 * 
 * 版本: [1.0]
 * 功能说明: 鉴权请求消息命令处理器
 * @Author 作者 : zdy
 * @CreateDate 创建时间: 2021-02-30
 */
@Component
//@ApiDoc(module = "WebSocket 项目文档",group = "SOCKET-GROUP")
public class AuthRequestHandler extends AbstractCommandHandler
{
	@Override
	public Packet handler(Packet packet, ChannelContext channelContext) throws ImException
	{
//		if (packet.getBody() == null) {
//			RespBody respBody = new RespBody(Command.COMMAND_AUTH_RESP,ImStatus.C10010);
//			return ProtocolManager.Converter.respPacket(respBody, channelContext);
//		}
//		AuthReqBody authReqBody = JsonKit.toBean(packet.getBody(), AuthReqBody.class);
//		String token = authReqBody.getToken() == null ? "" : authReqBody.getToken();
//		String data = token +  ImConst.AUTH_KEY;
//		authReqBody.setToken(data);
//		authReqBody.setCmd(null);
//		RespBody respBody = new RespBody(Command.COMMAND_AUTH_RESP,ImStatus.C10009).setData(authReqBody);
//		return ProtocolManager.Converter.respPacket(respBody, channelContext);

		return null;
	}

	@Override
	public ICommand command() {
		return Command.COMMAND_AUTH_REQ;
	}
}
